package com.socialbank.web.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.github.pagehelper.PageInfo;
import com.socialbank.web.FinanceBean.BankMetal;
import com.socialbank.web.bean.ResultMessage;
import com.socialbank.web.service.BankMetalService;
import com.wqdata.auth.util.PageParam;

@Controller
@RequestMapping("/bank/metal")
public class BankMetalController {
	@Resource
	private BankMetalService bankMetalService;
	
	@RequestMapping("/save")
	@ResponseBody
	protected Object save(MultipartFile file,BankMetal bankMetal){
		bankMetalService.save(file, bankMetal);
		Map<String, Object> result = new HashMap<>();
		return new ResultMessage(200,"",result);
	} 
	@RequestMapping("/deleteById")
	@ResponseBody
	protected Object deleteById(String id){
		bankMetalService.deleteById(id);
		Map<String, Object> result = new HashMap<>();
		return new ResultMessage(200,"",result);
	} 
	@RequestMapping("/getList")
	@ResponseBody
	protected Object getList(PageParam pageParam,BankMetal bankMetal){
		PageInfo<BankMetal> pageinfo=bankMetalService.getList(pageParam,bankMetal);
		List<BankMetal> bankMetals=new ArrayList<BankMetal>();
		bankMetals=pageinfo.getList();
		Map<String, Object> result = new HashMap<>();
		result.put("data", bankMetals);
		return new ResultMessage(200,"",result);
	} 
	@RequestMapping("/findById")
	@ResponseBody
	protected Object findById(String id){
		BankMetal bankMetal=bankMetalService.findById(id);
		Map<String, Object> result = new HashMap<>();
		result.put("data", bankMetal);
		return new ResultMessage(200,"",result);
	} 
	@RequestMapping("/updateById")
	@ResponseBody
	protected Object updateById(MultipartFile file,BankMetal bankMetal){
		bankMetalService.updateById(file,bankMetal);
		Map<String, Object> result = new HashMap<>();
		return new ResultMessage(200,"",result);
	} 
	
}
